package com.cmcc.fj12580.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.cmcc.fj12580.R;

public class ForwardAdapter extends BaseAdapter {
	private LayoutInflater layoutInflater;
	private String inflater = Context.LAYOUT_INFLATER_SERVICE;
	private int selected;
	@SuppressWarnings("unused")
	private Context context;
	private List<String> list;

	public ForwardAdapter(Context context, List<String> list) {
		this.context = context;
		this.list = list;
		this.selected = 0;
		layoutInflater = (LayoutInflater) context.getSystemService(inflater);
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View layout = layoutInflater.inflate(R.layout.person_center_setting_function_forword_list, parent, false);

		ImageView iv2 = (ImageView) layout.findViewById(R.id.ivConfirm);
		if (selected == position) {
			iv2.setImageResource(R.drawable.selecte_gou);
		}
		TextView tv = (TextView) layout.findViewById(R.id.tvColorSet);
		tv.setText(list.get(position));
		return layout;
	}

	public void setSelected(int index){
		selected=index;
		notifyDataSetChanged();
	}
}